<%@ page language="java" isELIgnored="false" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>航空公司走势对比（航班）——恒拓运价魔方</title>
<link rel="stylesheet" href="http://qunarzz.com/home/prd/styles/geilivible/release/home-2013012823365302.css">
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/show.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/datePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/lib/ligerUI/js/ligerui.min.js"></script>
<link href="<%=request.getContextPath() %>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath() %>/FusionCharts/FusionCharts.js"></script>
<link href="<%=request.getContextPath() %>/fare/css/base.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/jsFile/common.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/jsFile/multiblepicker.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/jsFile/FDCDialog.js"></script>

<link href='<%=request.getContextPath()%>/fare/js/cityquery/cityquery.css' rel="stylesheet" type="text/css" />
<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/citylist.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/querycity.js'></script>
<script>

var columns_main = [
			   { display: '航段', name: 'line', minWidth: 100 },
               { display: '航班日期', name: 'date', minWidth: 140 },
               { display: '起飞时间', name: 'flightBatchStartTime',minWidth: 100 },
               { display: '最低价', name: 'czPrice' },
               { display: '代理人最低价', name: 'agentPrice' },
               { display: '差价比例', name: 'pricescale' },
               { display: '网站名称', name: 'siteName' },
               { display: '航班号', name: 'flightNo' },
               { display: '代理人名称', name: 'agentName' }
               ];

function showm(sid){

var which = document.getElementById("lite" + sid);
var imgmenu = document.getElementById("ling" + sid);
	if (which.style.display == "none"){
		document.getElementById("lite" + sid).style.display="";
	}
	else{
		document.getElementById("lite" + sid).style.display="none";
	}

}

function currentDate(){ 
    var now = new Date();       
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
   
    var today = year + "-";       
    if(month < 10)
        today += "0";       
    today += month + "-";       
    if(day < 10)
        today += "0";           
    today += day;       
    return(today); 
}

$(function(){
	var grid = $("#maingrid");
	loadAndDisplayData(grid,'lowestPriceCompareAction!analyse.action');
	grid.ligerGrid({
        height:'200px',
        columns:columns_main
    });
	var columns = [ { display: '网站名称', name: 'channel', align: 'center', width: 440, minWidth: 60 } ];
	registPicker('channels',"pageUtilAction!channelsNotNanHang.action",columns,540,'channel');
	$('#depCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	$('#arrCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	var dataGridColumns = [{ header: '航空公司名', name: 'name' }];
	registSimplePicker('carriers',"pageUtilAction!carriers.action",dataGridColumns,150,'name');
	if($('#grapDate').val()==''){
		$('#grapDate').val(currentDate());
	}
	if($('#depTimeHour1').val()==''){
		$('#depTimeHour1').val('00');
		$('#depTimeMin1').val('00');
		$('#depTimeHour2').val('23');
		$('#depTimeMin2').val('59');
	}
})

function loadAndDisplayData(grid,url){
	if($('#depCity').val()!=''&&$('#arrCity').val()!=''){
		$.ajax({
	        url : url,
	        data:{
	        	airLineCompany:$('#airLineCompany').val(),
	        	depCity:$('#depCity').val(),
	        	arrCity:$('#arrCity').val(),
	        	beginDateAfterToday:$('#beginDateAfterToday').val(),
	        	endDateAfterToday:$('#endDateAfterToday').val(),
	        	channels:$('#channels').val(),   
	        	priceType:$('#priceType').val(),
	        	grapDate:$('#grapDate').val(),
	        	depTimeHour1:$('#depTimeHour1').val(),
	        	depTimeHour2:$('#depTimeHour2').val(),
	        	depTimeMin1:$('#depTimeMin1').val(),
	        	depTimeMin2:$('#depTimeMin2').val(),
	        	bookingType:$('#bookingType').val()
	        	},
	        cache : false, 
	        async : false,
	        type : "POST",
	       	complete: function(jqXHR, textStatus){
	       		if(jqXHR.status==200){
	       			result = parseObj(jqXHR.responseText)
	       			var data = result.json;
		        	var xml = result.xml;
		        	grid.ligerGrid({
		        		height:'300px',
		                columns:columns_main,
		                data:data,
		                pageSize:10,
		                rownumbers:true
		            });
		        	if(data.Total!=0){
	       				$("#norecord").attr('style','display:none');
	       				$("#maingrid").attr('style','margin-top:30px;');
	       			}else{
	       				$("#norecord").attr('style','margin-top:30px;margin-bottom:1px;display:block;color:red');
	       				$("#maingrid").attr('style','margin-top:1px;');
	       				
	       			}
		        	$('#text').val(xml);
		        	setChart();
	       		}else{
	       			alert('查询失败,请与管理员联系');
	       		}
	       	}
	    });
	}
	FDCDialog.unLockWindow();
}

function changeAction(url){
	$('#channel').attr('action',url);
}

function checkiForm(){
	if($('#depCity').val()=='中文/拼音' || $('#arrCity').val()=='中文/拼音'){
		if(!window.confirm('航段不选，查询比较耗时，是否继续？')){
	        return false;
	     }
	}
	if($("#beginDateAfterToday").val()!=parseInt($("#beginDateAfterToday").val()) || $("#beginDateAfterToday").val()*1<0 || $("#beginDateAfterToday").val()*1>180){	
		alert("航班日期:未来_到_天航班 只能为整数,范围0-180天!");
		$("#beginDateAfterToday").focus();
		return false;
	}
	$("#beginDateAfterToday").val(parseInt($("#beginDateAfterToday").val()));
	
	if($("#endDateAfterToday").val()!=parseInt($("#endDateAfterToday").val()) || $("#endDateAfterToday").val()*1<0 || $("#endDateAfterToday").val()*1>180){	
		alert("航班日期:未来_到_天航班 只能为整数,范围0-180天!");
		$("#endDateAfterToday").focus();
		return false;
	}
	$("#endDateAfterToday").val(parseInt($("#endDateAfterToday").val()));

	
	return true;
}

function checkJspForm(){
	if(!checkiForm()){
		return false;
	}
	//目前的数据时净价和预订,临时解决方案
	if($('#priceType').val()=='2' || $('#bookingType').val()=='2'){
		$('#maingrid').ligerGrid({
    		height:'300px',
            columns:columns_main,
            data:null,
            pageSize:10,
            rownumbers:true
        });
		$("#norecord").attr('style','margin-top:30px;margin-bottom:1px;display:block;color:red');
		$("#maingrid").attr('style','margin-top:1px;');
		$("#chartContainer").hide();
		return false;
	}
	changeAction('lowestPriceCompareAction!toAnalyseJSP.action');
	FDCDialog.lockWindow(true,'<%=request.getContextPath() %>');
	setTimeout(function(){loadAndDisplayData($('#maingrid'),'lowestPriceCompareAction!analyse.action');},1);
}

function resetForm(){
	
}

function bhdb(){
	
}
function whdb(){
	
}

</script>
<style type="text/css">
<!--
.STYLE1 {
	color: #990000;
	font-weight: bold;
}
-->
</style>
</head>

<body>
<jsp:include page="/pages/system/feedback/feedback.jsp" ></jsp:include>
<div class="main">
<div class="sideBar">
<div class="box">

    <div class="line"></div>
</div>
</div>
<div class="content"> 

<form id="channel"  method="POST">
<TABLE cellSpacing=1 cellPadding=3 width="100%" style="border-collapse: separate;border-spacing: 1px;" border=0 class="tabg">
  <TR class="tr1">
    <TD colspan="4">查询条件 </TD>
  </TR>
  <TR class="tab">
    <TD width="10%" height="26" class="td1" style="text-align:left">航空公司：</TD>
    <TD width="40%" colspan="3">
      	<select class="easyui-combobox" name="airLineCompany" style="width: 150px;" id="airLineCompany">
				<option value="" selected="selected">全部</option>
				<c:choose>
					<c:when test="${sourceList == null}">
					</c:when>
					<c:otherwise>
						<c:forEach var="item" items="${sourceList}">
							<option value="${item.name}">${item.name}</option>
						</c:forEach>
					</c:otherwise>
				</c:choose>
		
		</select>
		<span style="color: #ff0000">*</span>
    </TD>
  </TR>
  <TR class="tab">
    <TD width="10%" height="26" class="td1" style="text-align:left">航&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;线：</TD>
    <TD width="40%">
      <input type="text" name="depCity" style="width:100px" id="depCity" value="广州">
      <span>至</span>
      <input type="text" name="arrCity" style="width:100px" id="arrCity" value="大连">
      <span style="color: #ff0000">*</span>
    </TD>
    <TD width="10%" height="26" class="td1" style="text-align:left">航班：</TD>
  	<TD width="40%"><input type="text" name="airLine" style="width:100px" id="airLine" value="CZ3101"> 08:00 <span style="color: #ff0000">*</span>
  	</TD>
  </TR>
  <TR class="tab">
   <TD width="10%" height="26" class="td1" style="text-align:left"><input id="airLineDateType" name="airLineDateType" value="1" type="radio" checked="checked">航班日期：</TD>
    <TD>
      <input name="airLineStartDate" type="text" id="airLineStartDate" style="width:100px" value="${airLineStartDate}"  onClick="WdatePicker()">
      <span>至</span>
      <input name="airLineEndDate" type="text" id="airLineEndDate" style="width:100px" value="${airLineEndDate}"  onClick="WdatePicker()"><span style="color: #ff0000">*</span>
	</TD>
  	<TD class="td1" style="text-align:left"><input id="airLineDateType" name="airLineDateType" value="2" type="radio">未来天数：</TD>
  	<TD>
  	 <input type="text" style="width:30px" maxlength="2" name="futureDays" id="futureDays" value="${futureDays }" required onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">天
  	</TD>
  </TR>
  
  <tr>
  	<td colspan="4">
  		<table style="width:100%">
  			<tr>
  				<th width="10%" align="center"><div onclick="bhdb();">&nbsp;&nbsp;本行自比&nbsp;&nbsp;</div></th><th width="10%" align="center"><div onclick="whdb();">&nbsp;&nbsp;外航对比&nbsp;&nbsp;</div></th><th colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;</th>
  			</tr>
  		</table>
	</td>
  </tr>
  
  
  <TR class="tab">
  	<TD height="26" class="td1" style="text-align:left">比较航班：</TD>
  	<TD>
  	  <input name="contrastAirLines" type="text" id="contrastAirLines" style="width:150px" value="CZ3102;CZ3103">
  	</TD>
  	<TD class="td1" style="text-align:left">舱位等级</TD>
  	<TD><select name="cabinClass" id="cabinClass" style="width:100px">
  	    <option value="0">ALL</option>
        <option value="1">经济舱</option>
      </select>
  	</TD>
  </TR>
  
  <TR class="tab">
  	<TD height="26" class="td1" style="text-align:left">&nbsp;</TD>
  	<TD colspan="3" align="left">
  	  <input name="airCompanyName" type="text" id="airCompanyName" style="width:100px" value="中国南方航空公司">
  	  <input name="contrastAirLine" type="text" id=contrastAirLine style="width:100px" value="CZ3103"> 08:30  &nbsp;&nbsp;<input type="button" value="添加" id="Submit2" onclick="" style="width:80px;">
  	</TD>
  </TR>
  <TR class="tab">
    <TD class="td1" style="text-align:left">数据来源：</TD>
    <TD>
     	<select class="easyui-combobox" name="channel" style="width: 150px;" id="channel">
				<option value="" selected="selected">--请选择--</option>
				<c:choose>
					<c:when test="${channelSourceList == null}">
					</c:when>
					<c:otherwise>
						<c:forEach var="item" items="${channelSourceList }">
							<option value="${item.id}">${item.name}</option>
						</c:forEach>
					</c:otherwise>
				</c:choose>
		</select>
		<span style="color:red">若不选则默认为航空公司官网</span>
	</TD>
	<td colspan="2">&nbsp;</TD>
  </TR>
  
  <TR class="tab">
    <TD height="26" align="center" colspan="4">
      <input type="button" value="查询" id="Submit2" onclick="javascript:checkJspForm();" style="width:80px;">
      <input type="button" name="Submit222" value="清空" onclick="javascript:resetForm();" id="Submit222" style="width:80px;">
    </TD>
  </TR>
</TABLE>
</form>

<p></p>
<div id="norecord" style="margin-bottom:1px;display:none">系统搜索不到该数据，请重新查询！</div>
<p></p>
<div id="area_chart"
	style=" padding-bottom: 10px; font-size: 16px; color: #0653A1; padding: 0px 0px 0px 40px; width: 860px; float: left;">
	<div class="mainrtltext">航空公司走势对比（航班）</div>
	<div id="chartContainer"
		style="padding-bottom: 5px; width: 100%; height: 400;overflow-x:scroll;"></div>
  <div style="display:none"><input id="text" type="text" value="<s:property value="xml"/>"></div>
  <script language="JavaScript">
	function setChart(){
		$("#chartContainer").show();
	 	var xml = document.getElementById('text').value;
	 	var width = '750';
	 	var dateDiffs = parseInt($("#endDateAfterToday").val())*1 - parseInt($("#beginDateAfterToday").val())*1;
	 	if(dateDiffs*1>15){
	 		width = (750*1 + (dateDiffs*1-15)*50)+'';
	 		$('#area_chart').css('width','980px');
	 	}
		var chart2 = new FusionCharts("<%=request.getContextPath() %>/FusionCharts/MSLine.swf", "chart2Id", width, "350");
		chart2.setDataXML(xml);
		chart2.render("chartContainer");	
 	}
	</script>
</div>

</div>
</div>
</body>
</html>

